#include <iostream>
#include <thread>
#include <chrono>

void Add(long long n, long long m)
{   
    long long sum = 0;
    auto start = std::chrono::high_resolution_clock::now();
    for(long long i = n; i <= m; ++i)
    {
        sum += i;
    } 
    // std::chrono::milliseconds毫秒 std::chrono::microseconds微秒
    std::this_thread::sleep_for(std::chrono::milliseconds(100)); // 休眠
    auto end = std::chrono::high_resolution_clock::now();
    auto durtion = std::chrono::duration_cast<std::chrono::microseconds>(end-start); // 微秒
    std::cout  << sum << "\t Cost:" << std::fixed << durtion.count() * 1.0 / 1000000 << "s." << std::endl;
}


int main(int argc, char** argv)
{   
    std::thread t1(Add, 1, 1000000000);
    std::thread t2 = std::thread(Add, 1, 100);
    
    t1.join();
    t2.join();
    return 0;
}